package com.jinlejia.feedback.question.adapter.question;

import android.text.TextUtils;

import com.bumptech.glide.Glide;
import com.jinlejia.feedback.R;
import com.jinlejia.feedback.databinding.FbIncludeUserInfoLayoutBinding;
import com.jinlejia.feedback.question.http.QuestionDetailsHelper;

import java.util.Map;

/**
 * Created by Administrator on 2019/6/21.
 */

public final class KeyHelper {
    public final static String LocalReplyIsFirst = "$local_ReplyIsFirst";
    public final static String LocalIsShowAll = "$local_IsShowAll";
    public final static String LocalReplyIsLasted = "$local_ReplyIsLasted";
    public final static String LocalFollowIsLasted = "$local_FollowIsLasted";

    /**
     * 显示用户的信息
     * @param binding 用户信息include
     * @param userName 用户名称
     * @param userPortrait 用户头像
     * @param userDept 用户部门
     * @param userDuty 用户职位
     */
    public static void showUserInfo(FbIncludeUserInfoLayoutBinding binding,Object userName,Object userPortrait,Object userDept,Object userDuty){
        binding.userNameTextView.setText(String.valueOf(userName)); //用户名称
        //用户信息
        String userInfo = String.valueOf(userDuty); //用户职务
        String userDeptStr = String.valueOf(userDept); //用户部门
        if (!"null".equalsIgnoreCase(userDeptStr) && !TextUtils.isEmpty(userDeptStr)){
            //如果部门为null 则显示职务
            userInfo = userDeptStr;
        }
        binding.userInfoTextView.setText(userInfo);

        Glide.with(binding.userIconImageView.getContext())
                .load(String.valueOf(userPortrait))
                .placeholder(R.mipmap.jlj_role_head)
                .error(R.mipmap.jlj_role_head)
                .into(binding.userIconImageView);
    }

    public interface EventListener{
        void onSearchReply();
        void onLikeOperation(boolean currentState,String likeCode, QuestionDetailsHelper.LikeType likeType, Map<String, Object> map,int position);
        void onCollectOperation(boolean currentState,String problemCode,QuestionDetailsHelper.LikeType likeType,Map<String, Object> map,int position);

        void onReplyComment(String replyCode, String toUserId,String toUserName,int position);

        void onToAllReplyActivity(String replyCode);
    }

}
